package com.epam.kulibaba.components.compare.panelLevelUp;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.Reporter;

public class PanelLevelUp {
	public static final String PANELLEVELUP = "#page-breadcrumbs";
	public static final String CATEGORYMAINPAGELINK = "//div[@id = 'page-breadcrumbs']/a[1]";
	public static final String CATEGORYLEVELUPLINK = "//div[@id = 'page-breadcrumbs']/a[3]";
	
	@FindBy(css = PanelLevelUp.PANELLEVELUP)
	private WebElement panelLevelUp;
	
	@FindBy(xpath = PanelLevelUp.CATEGORYMAINPAGELINK)
	private WebElement categoryMainPageLink;
	
	@FindBy(xpath = PanelLevelUp.CATEGORYLEVELUPLINK)
	private WebElement categoryLevelUpLink;
	
	public WebElement getPanelLevelUp() {
		return panelLevelUp;
	}
	
	public WebElement getCategoryMainPage(){
		return categoryMainPageLink;
	}
	public WebElement getCategoryLevelUpLink() {
		return categoryLevelUpLink;
	}
	
	public static void goToCategoryLevelUp(PanelLevelUp panelLevelUp) {
		Reporter.log("Go back to catalog from product page");
		panelLevelUp.getCategoryLevelUpLink().click();
	}
	
	public static void goToMainPageFromCategory(PanelLevelUp categoryMainPageLink ){
		Reporter.log("goToMainPageFromCategory>");
		categoryMainPageLink.getCategoryMainPage().click();
	} 
	
	public  PanelLevelUp getPanelLevelUp(WebDriver driver) {
		PanelLevelUp panelLevelUp = PageFactory.initElements(driver,
				PanelLevelUp.class);		
		return panelLevelUp;
	}
}
